from selenium import webdriver
from Base.PublicFunction import OpenBroswer
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

class Stu_Sys_Mamagement():
    def __init__(self):
        self.dr = OpenBroswer.openbrower()
        self.dr.get('http://10.10.10.171:8080/WoniuBoss4.0/login')
        self.dr.find_element_by_name('userName').send_keys('WNCD000')
        self.dr.find_element_by_name('userPass').send_keys('woniu123')
        self.dr.find_element_by_xpath('/html/body/div[1]/div/div/div[2]/button').click()

    def findElement(self, locator):
        ele = WebDriverWait(self.dr, 10, 0.1).until(EC.presence_of_element_located(locator))
        return ele

    # def get_home_userame_obj(self):
    #     return self.dr.find_element_by_name('userName')  #用户名
    # def get_home_password_obj(self):
    #     return self.dr.find_element_by_name('userPass')   #密码
    # def get_home_login_obj(self):
    #     return self.dr.find_element_by_xpath('/html/body/div[1]/div/div/div[2]/button')    #登录按钮
    def get_home_student_obj(self):
        locator = (By.XPATH, "/html/body/div[4]/div[2]/div[6]/div[1]/a")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[4]/div[2]/div[6]/div[1]/a')   #学员管理按钮
    def get_home_stu_info_obj(self):
        locator = (By.XPATH, "/html/body/div[4]/div[2]/div[6]/div[2]/div/ul/li[1]/a")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[4]/div[2]/div[6]/div[2]/div/ul/li[1]/a') #学员信息
    def get_home_area_obj(self):
        locator = (By.XPATH, "/html/body/div[8]/div[2]/div/div/div/div[1]/select[1]")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[2]/div/div/div/div[1]/select[1]')   #[区域]下拉框
    def get_home_dire_obj(self):
        locator = (By.XPATH, "/html/body/div[8]/div[2]/div/div/div/div[1]/select[2]")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[2]/div/div/div/div[1]/select[2]')  #方向下拉框
    def get_home_class_obj(self):
        locator = (By.XPATH, "/html/body/div[8]/div[2]/div/div/div/div[1]/select[3]")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[2]/div/div/div/div[1]/select[3]')  #班级下拉框
    def get_home_status_obj(self):
        locator = (By.XPATH, "/html/body/div[8]/div[2]/div/div/div/div[1]/select[4]")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[2]/div/div/div/div[1]/select[4]')  #状态下拉框
    def get_home_stu_name_obj(self):
        locator = (By.NAME, "stuName")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_name('stuName')    #学生姓名框
    def get_home_search_obj(self):
        locator = (By.XPATH, "/html/body/div[8]/div[2]/div/div/div/div[1]/button")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[2]/div/div/div/div[1]/button')  #搜索按钮
    def get_home_decode_obj(self):
        locator = (By.XPATH, "//*[@id='btn-decrypt']")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('//*[@id="btn-decrypt"]')  #解密按钮
    def get_home_decode1_obj(self):
        locator = (By.NAME, "secondPass")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_name('secondPass')   #解密输入二位密码
    def get_home_access_obj(self):
        locator = (By.XPATH,"/html/body/div[10]/div/div/div[3]/button")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[10]/div/div/div[3]/button')  #确认按钮
    def get_home_alter_obj(self):
        locator = (By.XPATH, "/html/body/div[7]/div[2]/div/div/div/div[2]/div[2]/div[2]/table/tbody/tr/td[12]/button[2]")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[7]/div[2]/div/div/div/div[2]/div[2]/div[2]/table/tbody/tr/td[12]/button[2]')  #修改按钮
    def get_home_edu_obj(self):
        locator = (By.XPATH, "/html/body/div[11]/div/div/form/div/div[3]/div[2]/select")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[11]/div/div/form/div/div[3]/div[2]/select')  #学历下拉框
    def get_home_save_obj(self):
        locator = (By.XPATH, "/html/body/div[11]/div/div/div[2]/button")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[11]/div/div/div[2]/button')   #保存按钮
    def get_home_access1_obj(self):
        locator = (By.XPATH, "/html/body/div[12]/div/div/div[3]/button")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[12]/div/div/div[3]/button')  #修改完后的确认按钮
    def get_home_close_obj(self):
        return self.dr.close()
    def get_home_staff_name_obj(self):
        locator = (By.NAME, "empName")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_name('empName')   #员工姓名框
    def get_home_user_name_obj(self):
        locator = (By.NAME, "userName")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_name('userName')  #用户名框
    def get_home_search1_obj(self):
        locator = (By.XPATH, "/html/body/div[8]/div[2]/div/button")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[2]/div/button')    #用户查询按钮
    def get_home_role_obj(self):
        locator = (By.XPATH, "/html/body/div[8]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr/td[8]/button[1]")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr/td[8]/button[1]')    #角色按钮
    def get_home_addrole_obj(self):
        locator = (By.ID, "role_tree_3_check")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_id('role_tree_3_check')    #增加角色标识
    def get_home_access2_obj(self):
        locator = (By.ID, "saveSetRole")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_id('saveSetRole')      #修改保存按钮
    def get_home_access3_obj(self):
        locator = (By.XPATH, "/html/body/div[14]/div/div/div[3]/button")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[14]/div/div/div[3]/button')    #再次确认按钮
    def get_home_closedoc_obj(self):
        locator = (By.XPATH, "/html/body/div[12]/div/div/div[1]/button")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[12]/div/div/div[1]/button')   #关闭修改窗口
    def get_home_alterrole_obj(self):
        locator = (By.XPATH, "/html/body/div[8]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr/td[8]/button[2]")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr/td[8]/button[2]')  #修改按钮
    def get_home_alterrole1_obj(self):
        locator = (By.NAME, "user.des")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_name('user.des')  #修改用户描述
    def get_home_saveuser_obj(self):
        locator = (By.ID, "saveSetUser")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_id('saveSetUser')   #保存按钮
    def get_home_alterpwd_obj(self):
        locator = (By.XPATH, "/html/body/div[8]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr/td[8]/button[3]")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr/td[8]/button[3]')   #重置密码按钮
    def get_home_pwd_obj(self):
        locator = (By.XPATH, "/html/body/div[12]/div/div/form/div/div[2]/div/input")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[12]/div/div/form/div/div[2]/div/input')  #密码框
    def get_home_savepwd_obj(self):
        locator = (By.ID, "saveReset")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_id('saveReset')      #提交按钮
    def get_home_access4_obj(self):
        locator = (By.XPATH, "/html/body/div[14]/div/div/div[3]/button")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[14]/div/div/div[3]/button')   #重置密码确认按钮
    def get_home_access5_obj(self):
        locator = (By.XPATH, "/html/body/div[13]/div/div/div[3]/button")
        ele = self.findElement(locator)
        return ele

        # return self.dr.find_element_by_xpath('/html/body/div[13]/div/div/div[3]/button')   #修改用户确认按钮
    def get_search(self):
        locator = (By.XPATH, "/html/body/div[8]/div[2]/div/button")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[2]/div/button')  #查询按钮
    def get_home_rolesearch_obj(self):
        locator = (By.NAME, "role_name")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_name('role_name')    #查询角色按钮
    def get_home_role_name_obj(self):
        locator = (By.XPATH, "/html/body/div[11]/div/div/form/div/div[1]/div/input")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[11]/div/div/form/div/div[1]/div/input')    #新增角色名框
    def get_home_roleadd_obj(self):
        locator = (By.XPATH, "/html/body/div[8]/div[2]/div/div/button")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[2]/div/div/button')    #角色新增按钮
    def get_home_save_role_obj(self):
        locator = (By.ID, "saveAddRole")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_id('saveAddRole')   #角色新增保存
    def get_home_access6_obj(self):
        locator = (By.XPATH, "/html/body/div[12]/div/div/div[3]/button")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[12]/div/div/div[3]/button')    #角色新增确认按钮
    def get_home_alter_role_obj(self):
        locator = (By.XPATH, "/html/body/div[8]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr/td[6]/button[2]")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr/td[6]/button[2]')  #修改角色按钮
    def get_home_role_alter_obj(self):
        locator = (By.ID, "saveEidtRole")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_id('saveEidtRole')
    def get_home_system_obj(self):
        locator = (By.XPATH, "/html/body/div[4]/div[2]/div[1]/div[1]/a")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[4]/div[2]/div[1]/div[1]/a')   #系统管理
    def get_home_system_user_obj(self):
        locator = (By.XPATH, "/html/body/div[4]/div[2]/div[1]/div[2]/div/ul/li[1]/a")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[4]/div[2]/div[1]/div[2]/div/ul/li[1]/a')  #用户管理
    def get_home_role1_obj(self):
        locator = (By.XPATH, "/html/body/div[4]/div[2]/div[1]/div[2]/div/ul/li[2]/a")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[4]/div[2]/div[1]/div[2]/div/ul/li[2]/a')   #角色管理
    def get_stu(self):
        locator = (By.XPATH, "/html/body/div[8]/div[2]/div/div/div/div[2]/div[2]/div[2]/table/tbody/tr/td[1]")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[2]/div/div/div/div[2]/div[2]/div[2]/table/tbody/tr/td[1]')    #学生姓名
    def get_user(self):
        locator = (By.XPATH, "/html/body/div[8]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr/td[2]")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr/td[2]')   #用户搜索断言
    def get_teacherdata(self):
        locator = (By.XPATH, "/html/body/div[8]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr/td[4]")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr/td[4]')   #用户描述断言
    def get_newrole(self):
        locator = (By.XPATH, "/html/body/div[8]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr[1]/td[1]")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[8]/div[3]/div/div[1]/div[2]/div[2]/table/tbody/tr[1]/td[1]')  #新增角色断言
    def get_role_data(self):
        locator = (By.XPATH, "/html/body/div[7]/div[2]/div/div/div/div[2]/div[2]/div[2]/table/tbody/tr[1]/td[9]")
        ele = self.findElement(locator)
        return ele
        # return self.dr.find_element_by_xpath('/html/body/div[7]/div[2]/div/div/div/div[2]/div[2]/div[2]/table/tbody/tr[1]/td[9]')  #修改学历断言